package com.nit.bike.mapper.bike;

import com.nit.bike.dto.bike.BikeRecordDTO;
import com.nit.bike.entity.bike.BikeRecordEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BikeRecordMapper {
    int deleteByPrimaryKey(Long bikeRecordId);

    int insert(BikeRecordEntity record);

    int insertSelective(BikeRecordEntity record);

    BikeRecordEntity selectByPrimaryKey(Long bikeRecordId);

    int updateByPrimaryKeySelective(BikeRecordEntity record);

    int updateByPrimaryKey(BikeRecordEntity record);

    @Select("<script>" +
            "select *, bike_record_id AS `key` " +
            "from basic_bike_record " +
            "where bike_id = #{bikeId}" +
            "<if test='bikeRecordType != null'>And bike_record_type = #{bikeRecordType} </if> " +
            "ORDER BY " +
            "<if test='sortField != null'>${sortField} ${sortOrder}, </if>" +
            "bike_record_id DESC" +
            "</script>")
    List<BikeRecordDTO> list4Table(@Param("bikeId") String bikeId,
                                   @Param("bikeRecordType") String bikeRecordType,
                                   @Param("sortField") String sortField,
                                   @Param("sortOrder") String sortOrder) throws Exception;
}
